package com.ds.bpm.userclient;

import com.ds.bpm.client.ProcessDefVersion;
import com.ds.bpm.client.event.BPDEvent;
import com.ds.bpm.client.event.BPDListener;
import com.ds.bpm.engine.BPMException;
import com.ds.esb.config.EsbBeanAnnotation;
import com.ds.esb.config.EsbFlowType;
import com.ds.org.OrgManager;
import com.ds.server.OrgManagerFactory;
import com.ds.vfs.Folder;

@EsbBeanAnnotation(id = "SyncProcessFolder", name = "流程文件夹本地同步", expressionArr = "SyncProcessFolder()",flowType = EsbFlowType.listener,desc = "流程文件夹本地同步")
public class SyncProcessFolder implements BPDListener {

    public void createProcessFolder(ProcessDefVersion processDefVersion) throws BPMException {
        OrgManager orgManager = OrgManagerFactory.getOrgManager();
        String versionid = processDefVersion.getProcessDefVersionId();
        Folder processFolder = null;
//        try {
//            processFolder = CtVfsFactory.getCtVfsService().mkDir(OrgConstants.WORKFLOWBASEPATH+OrgConstants.WORKFLOWFORMPATH  + versionid, processDefVersion.getProcessDefName());
//            List<ActivityDef> acs = processDefVersion.getAllActivityDefs();
//            String initPath = processFolder.getPath();
//            for (ActivityDef ac : acs) {
//                if (ac.getImplementation().equals(ActivityDefImpl.NO)) {
//                    Folder activityFolder = CtVfsFactory.getCtVfsService().mkDir(initPath + ac.getActivityDefId(), ac.getName());
//                }
//            }
//        } catch (JDSException e) {
//            e.printStackTrace();
//        }

    }


    @Override
    public void ProcessDefUpdated(BPDEvent event) throws BPMException {
        createProcessFolder((ProcessDefVersion) event.getSource());

    }

    @Override
    public void ProcessDefCreaded(BPDEvent event) throws BPMException {

    }

    @Override
    public void ProcessDefDeleted(BPDEvent event) throws BPMException {

    }

    @Override
    public void ProcessDefFreezed(BPDEvent event) throws BPMException {

    }

    @Override
    public void ProcessDefActivaed(BPDEvent event) throws BPMException {

    }
}
